package gui;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Point;

/**
 * 
 * @author Oscar
 * A animatio for text that goes up. Used when you place a Card
 * on the gameboard for example.
 */
public class RisingText implements AnimationInterface {
	//The position in the center panel.
	private Point pos;
	//The length of the animation in miliseconds
	private int length;
	//The text of the animation
	private String text;
	//The color of the text
	private Color color;
	//Counter for determining when the animation is done.
	private int counter = 0;
	
	public RisingText(Point p, String t, Color c, int l){
		pos = p;
		text = t;
		color = c;
		length = l;
	}

	@Override
	public void paintComponent(Graphics g) {
		g.setColor(color);
		g.setFont(new Font("Dialog", Font.BOLD, 14));
		g.drawString(text, pos.x-12, pos.y);
	}

	@Override
	public void nextFrame() {
		Point temp = pos;
		pos = new Point(temp.x, temp.y-1);
		counter++;
		//if(counter*GUIConstants.frameUpdateTime >= length)
			//AnimationUtil.removeAnimation(this);
	}
	
	@Override
	public boolean wantsToBeRemoved(){
		return counter*GUIConstants.frameUpdateTime >= length;
	}
}
